import Vue from 'vue'
import VueRouter from 'vue-router'

// 路由懒加载
const Home = () => import('views/home/Home')
const LoginView = () => import('views/loginView/LoginView')
const Login = () => import ('views/login/Login')
const Register = () => import('views/register/Register')
const Profile = () => import('views/profile/Profile')
const Content = () => import('views/content/Content')
const Setting = () => import('views/setting/Setting')
const Edit = () => import('views/edit/Edit')
const Detail = () => import('views/detail/Detail')

// 安装插件
Vue.use(VueRouter)

// 创建router
const routes = [
  {
    path: '/',
    component: Home
  },
  {
    path: '/home',
    component: Home
  },
  {
    path: '/profile',
    component: Profile,
    children: [
      {
        path: 'content',
        component: Content
      },
      {
        path: 'setting',
        component: Setting
      },
      {
        path: 'edit',
        component: Edit
      }
    ]
  },
  {
    path: '/loginView',
    component: LoginView,
    children: [
      {
        path: 'login',
        component: Login
      },
      {
        path: 'register',
        component: Register
      }
    ]
  },
  {
    path: '/detail',
    component: Detail
  }
]

const router = new VueRouter({
  routes,
  mode: 'history'
})

export default router